package com.dj.mingkong.admin.biz.controller.music;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dj.mingkong.admin.biz.controller.music.vo.request.MusicianFansQueryVo;
import com.dj.mingkong.admin.biz.controller.music.vo.response.MusicianFansVo;
import com.dj.mingkong.admin.biz.service.music.MusicianFansService;
import com.dj.mingkong.common.annotation.HasRoles;
import com.dj.mingkong.common.enums.RoleEnum;
import com.dj.mingkong.common.infrastructure.base.dto.page.PageVo;
import com.dj.mingkong.common.infrastructure.base.dto.rest.RestResponse;
import com.dj.mingkong.common.util.AssertUtils;
import com.dj.mingkong.common.util.SmartBeanCopy;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 音乐人粉丝管理
 *
 * @author zenglonghui
 * @date: 2022/12/9 11:08
 */
@RestController
@RequestMapping("/musician/fans")
@HasRoles(RoleEnum.ADMIN)
public class MusicianFansController {
    @Resource
    private MusicianFansService musicianFansService;

    /**
     * 音乐人粉丝列表查询
     *
     * @param queryVo {}
     * @return MusicianFansVo
     */
    @PostMapping("/pageByVo")
    public RestResponse<PageVo<MusicianFansVo>> pageByVo(@RequestBody @Validated MusicianFansQueryVo queryVo) {
        AssertUtils.checkQueryPageVo(queryVo);
        final Page<MusicianFansVo> musicianFansVoPage = musicianFansService.pageByVo(queryVo);
        final PageVo<MusicianFansVo> pageVo = SmartBeanCopy.copyPageVo(musicianFansVoPage, MusicianFansVo.class);
        return RestResponse.success(pageVo);
    }
}
